/**
 * Created by JasonChou on 16/6/7.
 */

import Vue from 'vue'

Vue.filter('gender', function (gender) {
  if (gender == 1)
    return '男'
  else if (gender == 0)
    return '女'
  return '未知'
});

Vue.filter('phone', {
  read: function (phone, separator) {
    if (!separator)
      separator = ' ';

    phone += '';

    var res = '';
    var count = 0;
    var i = 0;
    for (i = phone.length - 1; i >= 0; i--) {

      count++;

      res = phone.charAt(i) + res;

      if (count == 4) {
        res = separator + res;
        count = 0;
      }

    }

    return res;

  },
  write: function (phone, separator) {
    if (!separator)
      separator = ' ';

    return phone.replace(new RegExp(separator), '');
  }
});
